package com.jie.common.enums;

import lombok.Getter;

/**
 * @author jie
 * @version 1.0 2025-02-16
 */
@Getter
public enum ApiRuleType {
    /**
     * 没有规则
     * */
    NO_RULE(0,"没有规则"),

    /**
     * 普通规则
     * */
    RULE(1,"普通规则"),

    /**
     * 深度规则
     * */
    DEPTH_RULE(2,"深度规则"),
    ;

    private final Integer code;

    private final String msg;

    ApiRuleType(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static String getMsg(Integer code) {
        for (ApiRuleType re : ApiRuleType.values()) {
            if (re.code.intValue() == code.intValue()) {
                return re.msg;
            }
        }
        return "";
    }

    public static ApiRuleType getRc(Integer code) {
        for (ApiRuleType re : ApiRuleType.values()) {
            if (re.code.intValue() == code.intValue()) {
                return re;
            }
        }
        return null;
    }
}
